#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int  N = 10010;
int main(){
  dp
    int n, k, t, xl, yd, xr, yu;
    int pass=0, stay=0, stayPoint=0; 
    scanf("%d%d%d%d%d%d%d",&n,&k,&t,&xl,&yd,&xr,&yu);
      int arr[20][1000];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2*t; j++) {
          scanf("%d",&arr[i][j]);
        }
    }
      for (int i = 0; i < n; i++) {
         int isPass=0, isStay=0;
         for (int j = 0; j < t; j++) {
           if (arr[i][j*2]>=xl&&arr[i][j*2]<=xr&&arr[i][j*2+1]>=yd&&arr[i][j*2+1]<=yu)
           {
              isPass=1;
              stayPoint++;
                if (stayPoint>=k)
                {
                    isStay=1;
                } 
           }
           else
           {
               stayPoint=0;
           }       
        } 

        if (isPass)
        {
            pass++;
        }
        if (isStay)
        {
            stay++;
        }       
    }
      printf("%d\n",pass);
      printf("%d",stay);    
}
